package com.k2data.app.k2bq.siem.request;

import com.k2data.app.k2bq.siem.common.GlobalVariables;

import java.util.HashMap;

public class RequestConfUtil {

    public static RequestConf getLoginRequest() {
        RequestConf rc = new RequestConf();
        rc.setUrl(GlobalVariables.URL + "/rs/esm/v2/login");
        rc.setMethod("POST");
        rc.setHeaders(new HashMap<>());
        rc.getHeaders().put("Content-Type", "application/json");
        rc.setBody(new HashMap<>());
        rc.getBody().put("username", GlobalVariables.USERNAME);
        rc.getBody().put("password", GlobalVariables.PASSWORD);
        rc.getBody().put("locale", "en_US");
        return rc;
    }

    public static RequestConf getRunningQueryRequest(String startTime, String endTime, String request) {
        RequestConf rc = new RequestConf();
        rc.setUrl(GlobalVariables.URL + "/rs/v1/runningQuery");
        rc.setMethod("POST");
        rc.setHeaders(new HashMap<>());
        rc.getHeaders().put("Content-Type", "application/json");
        rc.getHeaders().putAll(GlobalVariables.AUTH_HEADER);
        rc.setBodyStr(request.replace("startTime", startTime).replace("endTime", endTime));
        return rc;
    }

    public static RequestConf getResultRequest(String location) {
        RequestConf rc = new RequestConf();
        rc.setUrl(GlobalVariables.URL + "/rs" + location);
        rc.setMethod("GET");
        rc.setHeaders(new HashMap<>());
        rc.getHeaders().put("Content-Type", "application/json");
        rc.getHeaders().putAll(GlobalVariables.AUTH_HEADER);
        return rc;
    }

}
